Ext.define('ST2Demo.controller.Home', {
    extend: 'Ext.app.Controller',

    config: {
        //Contains references to view elements - getters are automatically generated
        refs: {
            tweetList: 'tweetlist'  //Creates getter method - this.getTweetList()
        },

        //Element event listeners
        control: {
            //Hooks into the 'itemtap' event of our tweet list, and calls the 'onTweetTap' method when that event fires
            tweetList: {
                itemtap: 'onTweetTap'
            }
        }
    },

    //Called when this controller is first created
    launch: function() {
        //Loads the tweets
        Ext.getStore('Tweets').load();
    },

    //Called when a user taps on an item in the tweetList.
    onTweetTap: function(list, index, target, record, e) {
        Ext.Msg.alert(ST2Demo.app.name, 'You tapped a tweet!  It was from: ' + record.get('from_user'));
    }
});

